"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CryptoJS = require('crypto-js');
var AESTool = {
    createKey: function () {
        var expect = 32;
        var str = Math.random().toString(36).substr(2);
        while (str.length < expect) {
            str += Math.random().toString(36).substr(2);
        }
        str = str.substr(0, 32);
        return str;
    },
    encrypt: function (data, secretKey) {
        var result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey), {
            iv: CryptoJS.enc.Utf8.parse('偏移量'),
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        return result.toString();
    },
    decrypt: function (cipher, secretKey) {
        var decrypted = CryptoJS.AES.decrypt(cipher, CryptoJS.enc.Utf8.parse(secretKey), {
            iv: CryptoJS.enc.Utf8.parse('偏移量'),
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        return CryptoJS.enc.Utf8.stringify(decrypted);
    }
};
exports.default = AESTool;
